package com.chouxiaozi.freemarker.controller;

import com.chouxiaozi.freemarker.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

@Controller
public class UserController {

    @GetMapping("/user")
    public String getUserList(Model model){
        List<User> list = new ArrayList<>();
        Random random = new Random();
        for (int i = 0; i < 10; i++) {
            list.add(new User("用户"+i,i+1,random.nextInt(3)));
        }
        model.addAttribute("list",list);
        return "user";
    }
}
